//
//  FindCarViewController.m
//  AutoHome
//
//  Created by Flying meat on 9/11/15.
//  Copyright (c) 2015 CaoFeng. All rights reserved.
//

#import "FindCarViewController.h"
#import "BrandCell.h"
#import "SecondCell.h"
#import "thirdCell.h"
#import "fourthCell.h"
#import "AFNetworking.h"
#import "HTTPRequestManager.h"
#import "HotModel.h"
#import "HotCell.h"
#import "UIImageView+AFNetworking.h"
@interface FindCarViewController ()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate>

{
    

    int _Stnum;
    
    int _countnum;
    
    NSArray *_searchArray;
    NSArray *_titleArray;
    NSArray *_hotArray;
    
    NSArray *_downArray;
    NSArray *_shaiArray;
    NSArray *_findArray;
    NSMutableArray *_dataArray;
    NSMutableArray *_levelArray;
}

@property (weak, nonatomic) IBOutlet UIView *FirstView;
@property (nonatomic,strong)UIView *rightView;
@property (nonatomic,strong)UIView *secondView;
@property (nonatomic,strong)UIView *ThirdView;
@property (nonatomic,strong)UIView *FourthView;

@property (nonatomic,strong)UIView *headtbView;
@property (nonatomic,strong)UIView *headtb2View;
@property (nonatomic,strong)UIView *headtb3View;
@property (nonatomic,strong)UIView *headtb4View;

@property (nonatomic,strong)UITableView *firstTableView;
@property (nonatomic,strong)UITableView *secondTableView;
@property (nonatomic,strong)UITableView *thirdTableView;
@property (nonatomic,strong)UITableView *fourthTableView;

@property (nonatomic,strong)UIButton *collectButton;
@property (nonatomic,strong)UIButton *historyButton;
@property (nonatomic,strong)UIButton *theHotButton;
@property (nonatomic,strong)UIButton *SecondViewButton;
@property (nonatomic,strong)UIButton *FourthViewButton;
@property (nonatomic,strong)UIButton *downButton;



@property (nonatomic,strong)UILabel *pirceLabel;
@property (nonatomic,strong)UILabel *sliderPrice;
@property (nonatomic,strong)UILabel *topdownLabel;
@property (nonatomic,strong)UILabel *collectLabel;
@property (nonatomic,strong)UILabel *historyLabel;
@property (nonatomic,strong)UILabel *theHotLabel;
@property (nonatomic,strong)UILabel *vertLabel;
@property (nonatomic,strong)UILabel *lable;
@property (nonatomic,strong)UILabel *segUnderLabel;
@property (nonatomic,strong)UILabel *labelWarnning;

@property (nonatomic,strong)UIImageView *headimgView;
@property (nonatomic,strong)UIImageView *headimgView2;
@property (nonatomic,strong)UIImageView *thirdScrollimgView;
@property (nonatomic,strong)UIImageView *imgcollect;
@property (nonatomic,strong)UIImageView *loadingView;
@property (nonatomic,strong)UIImageView *bluelodingView;

@property (nonatomic,strong)UITableView *hotTabelview;


@property (nonatomic,strong)UISlider *slider;
@property (nonatomic,strong)UIScrollView *thirdViewscroll;
@property (nonatomic,strong)UISegmentedControl *seg;



@end

@implementation FindCarViewController

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        
         self.seg.selectedSegmentIndex=0;
        _countnum=0;
        
        _downArray=[[NSArray alloc]init];
        _searchArray=[[NSArray alloc]init];
        
        _titleArray=[[NSArray alloc]init];

        _findArray=[[NSArray alloc]init];
        
        _hotArray=[[NSArray alloc]init];
        _shaiArray=[[NSArray alloc]init];
        _dataArray=[[NSMutableArray alloc]init];
        _levelArray=[[NSMutableArray alloc]init];
        
    _searchArray=@[@"❤️",@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"V",@"W",@"X",@"Y",@"Z"];

        
        _hotArray=@[@"大众",@"丰田",@"现代",@"奥迪",@"本田",@"福特",@"别克",@"长安",@"起亚",@"哈弗"];
        
        
        
        _titleArray=@[@[@"1"],@[@"ABT",@"阿尔法罗密欧",@"阿斯顿马丁",@"安凯客车",@"奥迪"],
                        @[@"BAC",@"巴博斯",@"宝骏",@"宝马",@"宝沃",@"保时捷",@"北京",@"北汽幻速",@"北汽威旺",@"北汽新能源",@"北汽制造",@"奔驰",@"奔腾",@"本田",@"比亚迪",@"别克",@"宾利",@"布加迪"],
                        @[@"昌河",@"成功汽车",@"长安",@"长安商用",@"长城"],
                        @[@"大迪",@"大发",@"大众",@"道奇",@"东风",@"东风风度",@"东风风神",@"东风风行",@"东风小康",@"东南",@"Datsun",@"DS"],
                        @[@"Elemental"],
                        @[@"法拉利",@"菲亚特",@"弗纳萨利",@"福迪",@"福汽启腾",@"福特",@"福田",@"FISKER",@"丰田"],
                        @[@"观致",@"光冈",@"广汽传祺",@"广汽吉奥",@"GMC",@"Gumpert"],
                        @[@"哈飞",@"哈弗",@"海格",@"海马",@"悍马",@"恒天",@"红旗",@"华凯",@"华利",@"华普",@"华骐",@"华颂",@"华泰",@"黄海",@"霍顿"],
                        @[@"Jeep",@"吉利汽车",@"佳跃",@"江淮",@"江铃",@"江铃集团轻汽",@"捷豹",@"金杯",@"金龙",@"金旅",@"九龙"],
                        @[@"卡尔森",@"卡威",@"开利",@"开瑞",@"凯佰赫",@"凯迪拉克",@"凯翼",@"康迪",@"科尼塞克",@"克莱斯勒",@"KTM"],
                        @[@"拉达",@"兰博基尼",@"蓝旗亚",@"朗世",@"劳伦士",@"劳斯莱斯",@"雷丁",@"雷克萨斯",@"雷诺",@"理念",@"力帆",@"莲花汽车",@"猎豹汽车",@"林肯",@"铃木",@"陆地方舟",@"陆风",@"路虎",@"路特斯",@"LOCAL MOTORS"],
                        @[@"马自达",@"玛莎拉蒂",@"迈巴赫",@"迈凯伦",@"摩根",@"MG",@"MiNi"],
                        @[@"NOBLE",@"纳智捷",@"南京京龙"],
                        @[@"讴歌",@"欧宝",@"欧朗",@"欧联"],
                        @[@"帕加尼",@"佩奇奥"],
                        @[@"奇瑞",@"启辰",@"起亚",@"前途",@"乔治巴顿"],
                        @[@"日产",@"荣威",@"如虎",@"瑞麒"],
                        @[@"萨博",@"赛麟",@"三菱",@"陕汽通家",@"上汽大众",@"世爵",@"双环",@"双龙",@"思铭",@"斯巴鲁",@"斯达泰克",@"斯柯达",@"Scion",@"smart",@"SPIRRA",@"SSC"],
                        @[@"TVR",@"塔塔",@"泰卡特",@"特斯拉",@"腾势"],
                        @[@"Venturi"],
                        @[@"W Motors",@"威麟",@"威兹曼",@"潍柴英致",@"沃尔沃",@"五菱汽车",@"五十铃"],
                        @[@"西雅特",@"现代",@"新凯",@"雪佛兰",@"雪铁龙"],
                        @[@"亚琛施纳泽",@"一汽",@"依维柯",@"英菲尼迪",@"永源",@"游侠",@"御捷"],
                        @[@"之诺",@"知豆",@"中华",@"中兴",@"众泰"]];
        
        _shaiArray=@[@"品牌",@"级别",@"国别",@"变速箱",@"结构",@"配置",@"排量",@"燃料",@"驱动",@"座位数"];
        
        _downArray=@[@"品牌",@"价格",@"级别",@"排序",@"北京"];
        
        _findArray=@[@"地区",@"品牌",@"价格",@"里程",@"车龄",@"级别",@"来源"];
    }
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    [self  setFourButton];
    [self setScrollView];

    [self setFirstView];
    [self setSecondView];
    [self setThirdView];
    [self setFourthView];
    
    
}

#pragma mark============= BiggestScrollView上4个带下划线按钮
-(void)setFourButton
{
    NSMutableAttributedString *first=[[NSMutableAttributedString alloc]initWithString:self.BrandButton.titleLabel.text];
    
    
    NSRange firstRange={0,[first length]};
    
    [first addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:firstRange];
    
    [self.BrandButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.BrandButton setAttributedTitle:first forState:UIControlStateNormal];
    
    
    
   
    
    
    
    NSMutableAttributedString *second=[[NSMutableAttributedString alloc]initWithString:self.ScreenButton.titleLabel.text];
    
    
    NSRange secondRange={0,[second length]};
    
    [second addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:secondRange];
    [self.ScreenButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.ScreenButton setAttributedTitle:second forState:UIControlStateNormal];
    
   
    
    
    
    NSMutableAttributedString *third=[[NSMutableAttributedString alloc]initWithString:self.DownPriceButton.titleLabel.text];
    
    
    NSRange thirdRange={0,[third length]};
    
    [third addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:thirdRange];
    [self.DownPriceButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.DownPriceButton setAttributedTitle:third forState:UIControlStateNormal];
    
  
    
    
    
    
    
    NSMutableAttributedString *fourth=[[NSMutableAttributedString alloc]initWithString:self.FindUsedCarButton.titleLabel.text];
    
    
    NSRange fourthRange={0,[fourth length]};
    
    [fourth addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:fourthRange];
    [self.FindUsedCarButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [self.FindUsedCarButton setAttributedTitle:fourth forState:UIControlStateNormal];
    
    
//    NSRange pushstrRange={0,[pushstr length]};
//    [pushstr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:pushstrRange];
//    [self.pushTitleButton setAttributedTitle:pushstr forState:UIControlStateNormal];
    
    
    
}






#pragma mark=========设置四个View在scroll上


-(void)setFirstView
{
    self.FirstView.backgroundColor=[UIColor whiteColor];
   
    
    self.firstTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.BiggestScroll.frame.size.height)];
    self.firstTableView.delegate=self;
    self.firstTableView.dataSource=self;
    self.firstTableView.tag=3001;
    [self.firstTableView registerNib:[UINib nibWithNibName:@"BrandCell" bundle:nil] forCellReuseIdentifier:@"BrandCell"];
    [self.firstTableView registerNib:[UINib nibWithNibName:@"BrandtwoCell" bundle:nil] forCellReuseIdentifier:@"BrandtwoCell"];
    [self.FirstView addSubview:self.firstTableView];
    
    
    
    self.headtbView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)];
    self.headtbView.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.05];
    
   
    
    
    self.collectButton=[[UIButton alloc]initWithFrame:CGRectMake(20, 0, 60, 60)];
    [self.collectButton addTarget:self action:@selector(collectView) forControlEvents:UIControlEventTouchUpInside];
    
    [self.collectButton setImage:[UIImage imageNamed:@"findcar_icon_collect.png"] forState:UIControlStateNormal];

    self.collectLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 50, 100,20)];
    self.collectLabel.text=@"我的收藏";
    self.collectLabel.textAlignment=NSTextAlignmentCenter;
    self.collectLabel.font=[UIFont systemFontOfSize:13];
    self.headimgView=[[UIImageView alloc]initWithFrame:CGRectMake(105, 0, 5, 70)];
    self.headimgView.image=[UIImage imageNamed:@"sideBar_shadow_bg.png"];


    
    
    
    
    
    self.historyButton=[[UIButton alloc]initWithFrame:CGRectMake(130,0, 60, 60)];
    
    [self.historyButton addTarget:self action:@selector(history) forControlEvents:UIControlEventTouchUpInside];
    
    [self.historyButton setImage:[UIImage imageNamed:@"icon_history.png"] forState:UIControlStateNormal];
    self.historyLabel=[[UILabel alloc]initWithFrame:CGRectMake(110, 50, 100,20)];
    self.historyLabel.text=@"浏览历史";
    self.historyLabel.textAlignment=NSTextAlignmentCenter;
    self.historyLabel.font=[UIFont systemFontOfSize:13];
    self.headimgView2=[[UIImageView alloc]initWithFrame:CGRectMake(205, 0, 5, 70)];
    self.headimgView2.image=[UIImage imageNamed:@"sideBar_shadow_bg.png"];
    


    
    
    
    self.theHotButton=[[UIButton alloc]initWithFrame:CGRectMake(230,0,60, 60)];
    
    [self.theHotButton addTarget:self action:@selector(hot) forControlEvents:UIControlEventTouchUpInside];
    [self.theHotButton setImage:[UIImage imageNamed:@"icon_hot.png"] forState:UIControlStateNormal];
    self.theHotLabel=[[UILabel alloc]initWithFrame:CGRectMake(210, 50, 100,20)];
    self.theHotLabel.text=@"热销排行";
    self.theHotLabel.textAlignment=NSTextAlignmentCenter;
    self.theHotLabel.font=[UIFont systemFontOfSize:13];


    
    
    
    
    [self.headtbView addSubview:self.headimgView];
    [self.headtbView addSubview:self.headimgView2];
    
    [self.headtbView addSubview:self.collectLabel];
   [self.headtbView addSubview:self.historyLabel];
    [self.headtbView addSubview:self.theHotLabel];
    [self.headtbView addSubview:self.theHotButton];
    [self.headtbView addSubview:self.historyButton];
    
    [self.headtbView addSubview:self.collectButton];

    
    self.firstTableView.tableHeaderView=self.headtbView;
    
    
    
    
    
    
    self.rightView=[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width, 65, self.view.frame.size.width, self.view.frame.size.height)];
    
    self.rightView.backgroundColor=[UIColor yellowColor];
    UIPanGestureRecognizer *pan=[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGes:)];
    [self.rightView addGestureRecognizer:pan];
    
    
    [self.FirstView addSubview:self.rightView];
    
    self.vertLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 2, self.rightView.frame.size.height)];
    self.vertLabel.backgroundColor=[UIColor lightGrayColor];
    [self.rightView addSubview:self.vertLabel];
    
    
    
    
    
}





-(void)panGes:(UIPanGestureRecognizer*)panGes
{
    CGPoint point=[panGes translationInView:self.rightView];
    if (panGes.state==UIGestureRecognizerStateChanged) {
        if (self.rightView.frame.origin.x<=230) {
            self.rightView.frame=CGRectMake(80+point.x, 0, self.view.frame.size.width, self.view.frame.size.height);
            
        }
    }
    else if (panGes.state==UIGestureRecognizerStateEnded)
        {
            if (self.rightView.frame.origin.x>150) {
                [self showmain];
              
            }else
            {
                
                [self showcollectView];
            }
                    }
    }


    


-(void)showmain
{
    [UIView animateWithDuration:0.5 animations:^{
        self.rightView.frame=CGRectMake(self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height-65);
        
    }];
    
    
}
-(void)showcollectView
{
    
    [UIView animateWithDuration:0.5 animations:^{

        self.rightView.frame=CGRectMake(80, 0, self.view.frame.size.width-80,self.view.frame.size.height-65);

    }];
    
    
}







#pragma mark==========按钮"我的收藏"推出的新界面;
-(void)collectView
{

    [self.hotTabelview removeFromSuperview];
    [self.loadingView removeFromSuperview];
    [self.bluelodingView removeFromSuperview];
    [self.seg removeFromSuperview];
    [self.segUnderLabel removeFromSuperview];
    self.rightView.backgroundColor=[UIColor whiteColor];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationBeginsFromCurrentState:2];
    
    self.rightView.frame=CGRectMake(80, 0, self.view.frame.size.width-80,self.view.frame.size.height-65);

    

    
    
    [self.imgcollect removeFromSuperview];
    [self.lable removeFromSuperview];
    
    //这里本来先要进行判断,查看数据库是否有值,若没有则显示此图片
    self.imgcollect=[[UIImageView alloc]initWithFrame:CGRectMake(80, 150, 80, 80)];
    self.imgcollect.image=[UIImage imageNamed:@"page_icon_empty.png"];
    [self.rightView addSubview:self.imgcollect];
 self.lable=[[UILabel alloc]initWithFrame:CGRectMake(68, 230, 140, 40)];
    
   self.lable.text=@"暂无收藏车系";
    self.lable.textColor=[UIColor grayColor];
    [self.rightView addSubview: self.lable];
    
    
    

    
    
    [UIView commitAnimations];
    
    
    
    
    
    
    
}
#pragma mark========history触发浏览历史按钮推出rightView
-(void)history
{
    [self.hotTabelview removeFromSuperview];
    
    [self.loadingView removeFromSuperview];
    [self.bluelodingView removeFromSuperview];
    [self.seg removeFromSuperview];
    [self.segUnderLabel removeFromSuperview];
    [self.imgcollect removeFromSuperview];
    [self.lable removeFromSuperview];

    self.rightView.backgroundColor=[UIColor whiteColor];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationBeginsFromCurrentState:2];
    
    self.rightView.frame=CGRectMake(80, 0, self.view.frame.size.width-80,self.view.frame.size.height-65);
    
    
    
    
    
    
    
    //这里本来先要进行判断,查看数据库是否有值,若没有则显示此图片
   self.imgcollect=[[UIImageView alloc]initWithFrame:CGRectMake(80, 150, 80, 80)];
    self.imgcollect.image=[UIImage imageNamed:@"page_icon_empty.png"];
    [self.rightView addSubview:self.imgcollect];
    self.lable=[[UILabel alloc]initWithFrame:CGRectMake(68, 230, 140, 40)];
    
    self.lable.text=@"暂无浏览历史车系";
    self.lable.textColor=[UIColor grayColor];
    [self.rightView addSubview: self.lable];
    
    
    
    
    
    
    [UIView commitAnimations];

    
    
    
    
    
}



#pragma mark========hot热销排行榜触发推出rightView
-(void)hot
{
    
    [self.loadingView removeFromSuperview];
    [self.bluelodingView removeFromSuperview];
    [self.seg removeFromSuperview];
    [self.segUnderLabel removeFromSuperview];
    [self.imgcollect removeFromSuperview];
    [self.lable removeFromSuperview];
    
    
    [self.imgcollect removeFromSuperview];
    [self.lable removeFromSuperview];

    self.rightView.backgroundColor=[UIColor whiteColor];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationBeginsFromCurrentState:2];
    
    self.rightView.frame=CGRectMake(80, 0, self.view.frame.size.width-80,self.view.frame.size.height-65);
    
    [UIView commitAnimations];

    
    
    
    
    
    //这里本来先要进行判断,查看数据库是否有值,若没有则显示此图片

    [self addNetObserve];
    
    
    
}



#pragma mark=====添加一个网络观察器
-(void)addNetObserve
{
    
    
    
    [[AFNetworkReachabilityManager sharedManager]startMonitoring];
    
    [[AFNetworkReachabilityManager sharedManager]setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        if (status==AFNetworkReachabilityStatusNotReachable) {
            
            
            
            self.rightView.backgroundColor=[UIColor whiteColor];
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationBeginsFromCurrentState:2];
            
            
            [self.loadingView removeFromSuperview];
            [self.bluelodingView removeFromSuperview];
            [self.seg removeFromSuperview];
            [self.segUnderLabel removeFromSuperview];
            [self.imgcollect removeFromSuperview];
            [self.lable removeFromSuperview];

            
            
            self.rightView.frame=CGRectMake(80, 0, self.view.frame.size.width-80,self.view.frame.size.height-65);
          self.imgcollect=[[UIImageView alloc]initWithFrame:CGRectMake(80, 150, 80, 80)];
            self.imgcollect.image=[UIImage imageNamed:@"pagefailed_bg_n.png"];
            [self.rightView addSubview:self.imgcollect];
            self.lable=[[UILabel alloc]initWithFrame:CGRectMake(68, 230, 140, 40)];
            
            self.lable.text=@"点击重新加载";
            self.lable.textColor=[UIColor grayColor];
            [self.rightView addSubview: self.lable];
            
            
            
            
           self.labelWarnning=[[UILabel alloc]initWithFrame:CGRectMake(0, 400, 240, 40)];
            self.labelWarnning.backgroundColor=[UIColor redColor];
            self.labelWarnning.font=[UIFont systemFontOfSize:15];
            self.labelWarnning.textAlignment=NSTextAlignmentCenter;
            
            
            self.labelWarnning.text=@"当前网络不可用,请检查网络设置";
            self.labelWarnning.textColor=[UIColor whiteColor];
            [self performSelector:@selector(labelWarnning:) withObject:self.labelWarnning afterDelay:4];
            
            [self.rightView addSubview:self.labelWarnning];
            [UIView commitAnimations];
            
            
            
            
        }
        else
        {
            [self.hotTabelview removeFromSuperview];
            [self.loadingView removeFromSuperview];
            [self.bluelodingView removeFromSuperview];
            [self.seg removeFromSuperview];
            [self.segUnderLabel removeFromSuperview];
            [self.imgcollect removeFromSuperview];
            [self.lable removeFromSuperview];
            [self.labelWarnning removeFromSuperview];

            
            

          
            
            self.rightView.backgroundColor=[UIColor whiteColor];
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationBeginsFromCurrentState:2];
            
            self.rightView.frame=CGRectMake(80, 0, self.view.frame.size.width-80,self.view.frame.size.height-65);

            self.seg=[[UISegmentedControl alloc]initWithItems:@[@"轿车",@"SUV",@"MPV"]];
            self.seg.frame=CGRectMake(5, 5, 230, 40);
            [self.rightView addSubview:self.seg];
    
            self.segUnderLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 49, self.rightView.frame.size.width, 5)];
            self.segUnderLabel.backgroundColor=[UIColor grayColor];
            
            self.seg.selectedSegmentIndex=_Stnum;
            
           
            [self.seg addTarget:self action:@selector(selectedSegmentIndex:) forControlEvents:UIControlEventValueChanged];
            
            [self.rightView addSubview:self.segUnderLabel];
            
            
            self.loadingView=[[UIImageView alloc]initWithFrame:CGRectMake(80, 200, 80, 80)];

            self.loadingView.image=[UIImage imageNamed:@"loadingpage_bg.png"];

            self.bluelodingView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 80, 80)];
            self.bluelodingView.image=[UIImage imageNamed:@"load_icon.png"];
            [self.loadingView addSubview:self.bluelodingView];
            
            [self.rightView addSubview:self.loadingView];
            


            CABasicAnimation *spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
            spinAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
            spinAnimation.fromValue = [NSNumber numberWithInt:0];
            spinAnimation.toValue = [NSNumber numberWithFloat:2 * M_PI];
            spinAnimation.duration = 2;
            spinAnimation.repeatCount = HUGE_VALF;
            [self.bluelodingView.layer addAnimation:spinAnimation forKey:@"GradientRotateAniamtion"];
           [UIView commitAnimations];
            
            
            [self performSelector:@selector(getInforFromNet) withObject:nil afterDelay:1];

        }
    }];
    
    
    
    
}

-(void)getInforFromNet
{
    
    
    [[HTTPRequestManager shareInstance]getCarWithPaiBySt:_Stnum success:^(id responseObject) {
        
        [_dataArray removeAllObjects];
       [_levelArray removeAllObjects];
        NSArray *array=responseObject;
        for (int i=0; i<array.count; i++) {
            NSDictionary *dic =array[i];
            NSArray *hotseriesArray=dic[@"hotseries"];
            NSString *levelname=dic[@"levelname"];

            NSMutableArray *levelArray=[[NSMutableArray alloc]init];
            for (int j=0; j<10; j++) {

            
                NSDictionary*dic2=hotseriesArray[j];
                HotModel *model=[HotModel new];
                model.img=dic2[@"img"];
                model.odercount=[NSString stringWithFormat:@"%@",dic2[@"ordercount"]];
                model.price=dic2[@"price"];
                model.seriesid=dic2[@"seriesid"];
                model.seriesname=dic2[@"seriesname"];
                [levelArray addObject:model];
        
            }
            NSArray *allarry=@[@{@"levelArray":levelArray,@"levelname":levelname}];
            [_dataArray addObject:allarry];
        }
       

        
        [self.bluelodingView removeFromSuperview];
        [self.loadingView removeFromSuperview];
        
        self.hotTabelview =[[UITableView alloc]initWithFrame:CGRectMake(0, 54, self.rightView.frame.size.width, self.rightView.frame.size.height-54)];
        self.hotTabelview.delegate=self;
        self.hotTabelview.dataSource=self;
        self.hotTabelview.tag=4001;
       
        [self.hotTabelview registerNib:[UINib nibWithNibName:@"HotCell" bundle:nil] forCellReuseIdentifier:@"HotCell"];
        
        [self.rightView addSubview:self.hotTabelview];
        
        [self.hotTabelview reloadData];
        
        
        
        
    } failure:^(NSError *error) {
    
        NSLog(@"排行榜请求失败,error==%@",error);
    }];
    

    
    
    
    
}




-(void)selectedSegmentIndex:(UISegmentedControl*)seg
{
    
    switch (seg.selectedSegmentIndex) {
        case 0:
            _Stnum=0;
            [self addNetObserve];
            break;
        case 1:
            _Stnum=1;
            [self addNetObserve];
            break;
        case 2:
            _Stnum=2;
            [self addNetObserve];
            break;
            
        default:
            break;
    }
    
    
    
    
}


-(void)labelWarnning:(UILabel*)label
{
    [UIView animateWithDuration:3 animations:^{
       label.hidden=YES;
    }];
    
    
}





-(void)setSecondView
{
    
    
    
    
    
    
   self.secondView =[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width,0, self.view.frame.size.width, self.view.frame.size.height)];
    
    [self.BiggestScroll addSubview:self.secondView];

    
    self.secondTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.BiggestScroll.frame.size.height)];

  
    self.secondTableView.delegate=self;
    self.secondTableView.dataSource=self;
    self.secondTableView.tag=3002;
  
    [self.secondView addSubview:self.secondTableView];
    
    
    
    self.headtb2View=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 80)];
    self.headtb2View.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.05];
    
    
    
    
    
    
    
    
    self.topdownLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 10)];
    self.topdownLabel.backgroundColor=[UIColor lightGrayColor];
    
    [self.headtb2View addSubview:self.topdownLabel];
    
    
    
    
    self.pirceLabel=[[UILabel alloc]initWithFrame:CGRectMake(20, 15, 60, 30)];
    self.pirceLabel.text=@"价格";
    self.pirceLabel.textColor=[UIColor blackColor];
     [self.headtb2View addSubview:self.pirceLabel];
    
    
    
    self.sliderPrice=[[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width-60, 15, 80, 30)];
 
    self.sliderPrice.textColor=[UIColor blueColor];
    [self.headtb2View addSubview:self.sliderPrice];
    
    
    
    
    
    
    self.slider=[[UISlider alloc]initWithFrame:CGRectMake(20, 40, 280, 20)];
    
    [self.headtb2View addSubview:self.slider];
    self.slider.minimumValue=0.0;
    self.slider.maximumValue=100.0;

    self.slider.value=0;
    
    self.slider.maximumTrackTintColor = [UIColor blueColor];
    
    //左侧条颜色
    self.slider.minimumTrackTintColor = [UIColor lightGrayColor];
    
    //滑块颜色
    
    [self.slider setThumbImage:[UIImage imageNamed:@"xiabashou@3x"] forState:UIControlStateHighlighted];
    [self.slider setThumbImage:[UIImage imageNamed:@"xiabashou@3x"] forState:UIControlStateNormal];
    [self.slider addTarget:self action:@selector(slider:) forControlEvents:UIControlEventValueChanged];

    self.secondTableView.tableHeaderView=self.headtb2View;
    
    
    
    [self.secondTableView registerNib:[UINib nibWithNibName:@"SecondCell" bundle:nil] forCellReuseIdentifier:@"SecondCell"];
    
    
    
    
    
    self.SecondViewButton=[UIButton buttonWithType:UIButtonTypeCustom];
    self.SecondViewButton.frame=CGRectMake(10,420, self.view.frame.size.width-20, 30);
    
    //这里滑块有一个数据下载,来使得button上的数字发生相应的变化,暂时不做了.
    self.SecondViewButton.titleLabel.text=[NSString stringWithFormat:@"共982个车系7139个车型 >"];
   
    
    self.SecondViewButton.titleLabel.textColor=[UIColor whiteColor];
    
    NSMutableAttributedString *secondstr=[[NSMutableAttributedString alloc]initWithString:self.SecondViewButton.titleLabel.text];
    NSRange secondRange={0,[secondstr length]};
    
    [secondstr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:secondRange];
    
    [self.SecondViewButton setAttributedTitle:secondstr forState:UIControlStateNormal];

    
    [self.secondView addSubview:self.SecondViewButton];
    [self.SecondViewButton setBackgroundImage:[UIImage imageNamed:@"tag_three_second_v.png"] forState:UIControlStateNormal];
    
    
    
    
    
}
-(void)setThirdView
{
   self.ThirdView=[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*2, 0, self.view.frame.size.width, self.BiggestScroll.frame.size.height)];
    [self.BiggestScroll addSubview:self.ThirdView];
    
    self.thirdViewscroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
    self.thirdViewscroll.delegate=self;
    self.thirdViewscroll.tag=1002;
    self.thirdViewscroll.contentSize=CGSizeMake(400, 0);
    self.thirdViewscroll.backgroundColor=[UIColor whiteColor];
    self.thirdViewscroll.showsHorizontalScrollIndicator=YES;
    [self.ThirdView addSubview:self.thirdViewscroll];
    
    
    self.thirdScrollimgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 400, 44)];
    self.thirdScrollimgView.image=[UIImage imageNamed:@"tagBar_bg_click.png"];
    [self.thirdViewscroll addSubview: self.thirdScrollimgView];
    
    
    for (int i=0; i<5; i++) {
        UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(i*80, 0, 60, 44)];
        NSMutableAttributedString *buttonstr=[[NSMutableAttributedString alloc]initWithString:_downArray[i]];
        NSRange buttonstrRange={0,[buttonstr length]};
        
        [buttonstr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:buttonstrRange];
        
        [button setAttributedTitle:buttonstr forState:UIControlStateNormal];
        
        [self.thirdViewscroll addSubview:button];
        
        
        UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(i*80+50, 12,20, 20)];
        imgView.image=[UIImage imageNamed:@"filterbar_icon_arrow.png"];
        [self.thirdViewscroll addSubview:imgView];
        
        
        
        //给第二层button添上分割线
        UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(i*78, 5, 2, 34)];
        label.backgroundColor=[UIColor lightGrayColor];
        
        [self.thirdViewscroll addSubview:label];
        
        
        
    }
 
    
    self.thirdTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 44, self.view.frame.size.width, self.BiggestScroll.frame.size.height)];
    
    
    self.thirdTableView.delegate=self;
    self.thirdTableView.dataSource=self;
    self.thirdTableView.tag=3003;
    
    [self.ThirdView addSubview:self.thirdTableView];
    
    
    
    [self.thirdTableView registerNib:[UINib nibWithNibName:@"thirdCell" bundle:nil] forCellReuseIdentifier:@"thirdCell"];
    
    
    
    
    
    
    
    
}
-(void)setFourthView
{
    
   self.FourthView =[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*3, 0, self.view.frame.size.width, self.BiggestScroll.frame.size.height)];
    
    self.FourthView.backgroundColor=[UIColor lightGrayColor];
    [self.BiggestScroll addSubview:self.FourthView];
    
    self.fourthTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.BiggestScroll.frame.size.height)];
    
    
    self.fourthTableView.delegate=self;
    self.fourthTableView.dataSource=self;
    self.fourthTableView.tag=3004;
    
    [self.FourthView addSubview:self.fourthTableView];

    
    [self.fourthTableView registerNib:[UINib nibWithNibName:@"fourthCell" bundle:nil] forCellReuseIdentifier:@"fourthCell"];
    
    
    
    
    
    
    self.FourthViewButton=[UIButton buttonWithType:UIButtonTypeCustom];
    self.FourthViewButton.frame=CGRectMake(10,400, self.view.frame.size.width-20, 30);
    
    //这里滑块有一个数据下载,来使得button上的数字发生相应的变化,暂时不做了.
    self.FourthViewButton.titleLabel.text=[NSString stringWithFormat:@"共340216车符合条件 >"];
    
    
    self.FourthViewButton.titleLabel.textColor=[UIColor whiteColor];
    
    NSMutableAttributedString *secondstr=[[NSMutableAttributedString alloc]initWithString:self.FourthViewButton.titleLabel.text];
    NSRange secondRange={0,[secondstr length]};
    
    [secondstr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:secondRange];
    
    [self.FourthViewButton setAttributedTitle:secondstr forState:UIControlStateNormal];
    
    
    [self.FourthView addSubview:self.FourthViewButton];
    [self.FourthViewButton setBackgroundImage:[UIImage imageNamed:@"tag_three_second_v.png"] forState:UIControlStateNormal];

    
    
    
}



-(void)slider:(UISlider *)slider
{
    if ((int)slider.value==0) {
        self.sliderPrice.text=@"不限";
       
    }
    else if ((int)slider.value==100)
    {
      self.sliderPrice.text=@"100万以上";
    }
    {
    self.sliderPrice.text=[NSString stringWithFormat:@"%d万",(int)slider.value];
       
        
    }
    
    
    
}



#pragma mark==========设置BiggestscrollVeiw

-(void)setScrollView
{
    
    
    self.BiggestScroll.contentSize=CGSizeMake(self.view.frame.size.width*4, 0);
    self.BiggestScroll.showsHorizontalScrollIndicator=YES;
    self.BiggestScroll.pagingEnabled=YES;

    self.BiggestScroll.contentOffset=CGPointMake(0, 0);
    self.BiggestScroll.userInteractionEnabled=YES;
    self.BiggestScroll.tag=1001;
    
    
}



#pragma mark==========按钮品牌触发的事件
- (IBAction)ToBrand:(id)sender {
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationBeginsFromCurrentState:3];
    
    
    self.ScrollLabel.frame=CGRectMake(10, 40, 50, 2);
    
    self.BiggestScroll.contentOffset=CGPointMake(0, 0);

    
    for (UIButton *button in self.allButtonView.subviews) {
        //如果是按钮则取反状态
        if ([button isKindOfClass:[UIButton class]]) {
            
            button.selected=NO;
            button.titleLabel.textColor=[UIColor darkGrayColor];
            
            
            
        }
    }
    self.BrandButton.selected=YES;
    self.BrandButton.titleLabel.textColor=[UIColor blueColor];
    self.BrandButton.backgroundColor=[UIColor clearColor];
   
    

    
    
    
    
    
    [UIView commitAnimations];
    
}






#pragma mark===========按钮筛选触发的事件
- (IBAction)ToScreen:(id)sender {
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationBeginsFromCurrentState:3];
    
    
    self.ScrollLabel.frame=CGRectMake(80, 40, 50, 2);
    
    self.BiggestScroll.contentOffset=CGPointMake(self.view.frame.size.width, 0);
    

    for (UIButton *button in self.allButtonView.subviews) {
        //如果是按钮则取反状态
        if ([button isKindOfClass:[UIButton class]]) {
            
            button.selected=NO;
            button.titleLabel.textColor=[UIColor darkGrayColor];
            
            
            
        }
    }
    self.ScreenButton.selected=YES;
    self.ScreenButton.titleLabel.textColor=[UIColor blueColor];
    self.ScreenButton.backgroundColor=[UIColor clearColor];
    
    
    

    [UIView commitAnimations];
    
}







#pragma mark===========按钮降价触发的事件
- (IBAction)ToDownPrice:(id)sender {
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationBeginsFromCurrentState:3];

    
    self.ScrollLabel.frame=CGRectMake(150, 40, 50, 2);
    self.BiggestScroll.contentOffset=CGPointMake(self.view.frame.size.width*2, 0);
    
    
    
    
    for (UIButton *button in self.allButtonView.subviews) {
        //如果是按钮则取反状态
        if ([button isKindOfClass:[UIButton class]]) {
            
            button.selected=NO;
            button.titleLabel.textColor=[UIColor darkGrayColor];
            
            
            
        }
    }
    self.DownPriceButton.selected=YES;
    self.DownPriceButton.titleLabel.textColor=[UIColor blueColor];
    self.DownPriceButton.backgroundColor=[UIColor clearColor];

    
    [UIView commitAnimations];
    
}







#pragma mark===========按钮找二手车触发的事件
- (IBAction)ToFindUsedCar:(id)sender {
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationBeginsFromCurrentState:3];
    
    
      self.ScrollLabel.frame=CGRectMake(210, 40, 70, 2);
    self.BiggestScroll.contentOffset=CGPointMake(self.view.frame.size.width*3, 0);

    
    for (UIButton *button in self.allButtonView.subviews) {
        //如果是按钮则取反状态
        if ([button isKindOfClass:[UIButton class]]) {
            
            button.selected=NO;
            button.titleLabel.textColor=[UIColor darkGrayColor];
            
            
            
        }
    }
    self.FindUsedCarButton.selected=YES;
    self.FindUsedCarButton.titleLabel.textColor=[UIColor blueColor];
    self.FindUsedCarButton.backgroundColor=[UIColor clearColor];
    
    
    
    [UIView commitAnimations];
    
}







#pragma mark============按钮搜索触发的事件
- (IBAction)SearchButton:(id)sender {
    
    
    
    
}





#pragma mark=======UIScrollViewDelegate

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    
    
    if (scrollView.tag==1001) {
        
    
    
    if (scrollView.contentOffset.x==0) {
        self.FirstView.backgroundColor=[UIColor yellowColor];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationBeginsFromCurrentState:3];
        
        
        for (UIButton *button in self.allButtonView.subviews) {
            //如果是按钮则取反状态
            if ([button isKindOfClass:[UIButton class]]) {
                
                button.selected=NO;
                button.titleLabel.textColor=[UIColor darkGrayColor];
                
                
                
            }
        }
        self.BrandButton.selected=YES;
        self.BrandButton.titleLabel.textColor=[UIColor blueColor];
        self.BrandButton.backgroundColor=[UIColor clearColor];
        
        
        
        self.ScrollLabel.frame=CGRectMake(10, 40, 50, 2);
        
        
        [UIView commitAnimations];    }
    else if (scrollView.contentOffset.x==self.view.frame.size.width )
    {
        
        
        self.secondView.backgroundColor=[UIColor whiteColor];

   
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationBeginsFromCurrentState:3];
        
        
        for (UIButton *button in self.allButtonView.subviews) {
            //如果是按钮则取反状态
            if ([button isKindOfClass:[UIButton class]]) {
                
                button.selected=NO;
                button.titleLabel.textColor=[UIColor darkGrayColor];
                
                
                
            }
        }
        self.ScreenButton.selected=YES;
        self.ScreenButton.titleLabel.textColor=[UIColor blueColor];
        self.ScreenButton.backgroundColor=[UIColor clearColor];
        
        
        self.ScrollLabel.frame=CGRectMake(80, 40, 50, 2);
        
        
        [UIView commitAnimations];
   
        
        
        
    }
    else if(scrollView.contentOffset.x==self.view.frame.size.width*2)
    {
        
        self.ThirdView.backgroundColor=[UIColor cyanColor];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationBeginsFromCurrentState:3];
        
        for (UIButton *button in self.allButtonView.subviews) {
            //如果是按钮则取反状态
            if ([button isKindOfClass:[UIButton class]]) {
                
                button.selected=NO;
                button.titleLabel.textColor=[UIColor darkGrayColor];
                
                
                
            }
        }
        self.DownPriceButton.selected=YES;
        self.DownPriceButton.titleLabel.textColor=[UIColor blueColor];
        self.DownPriceButton.backgroundColor=[UIColor clearColor];
        
        
        
        
        
        self.ScrollLabel.frame=CGRectMake(150, 40, 50, 2);
        
        
        [UIView commitAnimations];

        
        
    }
    else if (scrollView.contentOffset.x==self.view.frame.size.width*3)
    {
        self.FourthView.backgroundColor=[UIColor blueColor];
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationBeginsFromCurrentState:3];
        
        
        for (UIButton *button in self.allButtonView.subviews) {
            //如果是按钮则取反状态
            if ([button isKindOfClass:[UIButton class]]) {
                
                button.selected=NO;
                button.titleLabel.textColor=[UIColor darkGrayColor];
                
                
                
            }
        }
        self.FindUsedCarButton.selected=YES;
        self.FindUsedCarButton.titleLabel.textColor=[UIColor blueColor];
        self.FindUsedCarButton.backgroundColor=[UIColor clearColor];
        
        
        
        self.ScrollLabel.frame=CGRectMake(210, 40, 70, 2);
        
        
        [UIView commitAnimations];

    }else
    {
        
        NSLog(@"测试点被触发");
        
    }
    
    }else
    {
        
        NSLog(@"不是大scrollview");
        
        
    }
    
    
    
}


#pragma mark=================UITableViewDataSource,UITableViewDelegate


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.tag==3001) {
        if (section==0)
        {
        return 1;
        }
        else
        {
    
    NSArray *arry=_titleArray[section];
    
    
    return arry.count;
        }
    }
    
    else if (tableView.tag==3002)
    {
        return _shaiArray.count;
        
    }
    else if (tableView.tag==3003)
    {
        
        return 10;
        
    }
    else if (tableView.tag==3004)
    {
        
        return _findArray.count;
        
    }
    else if(tableView.tag==4001)
    {

        NSArray *array=_dataArray[section];
        NSDictionary *dic=array[0];
        NSArray *newarry=dic[@"levelArray"];
        
        
        return newarry.count;
        
        
    }
    else
    {
        
        return 1;
        
    }
    
}




-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (tableView.tag==3001) {
        
    
    return _searchArray.count;
    }
    else if (tableView.tag==3002)
    {
        return 1;
        
        
    }
    else if (tableView.tag==3003)
    {
        
        return 1;
        
        
    }
    else if(tableView.tag==3004)
    {
        return 1;
        
    }
    else if (tableView.tag==4001)
    {
     

        return _dataArray.count;
        
            }
    else
    {
        
        return 1;
    }
    
}


-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag==3001)
    {
        BrandCell*celltwo=[tableView dequeueReusableCellWithIdentifier:@"BrandtwoCell"];
    celltwo.accessoryType=UITableViewCellStyleDefault;
    _countnum=0;
        if (indexPath.section==0)
        {
            for (int i=0; i<2; i++) {
                for (int j=0; j<5; j++) {
                    self.button=[[UIButton alloc]initWithFrame:CGRectMake(j*60+10, i*70+10, 40,40)];
                    self.button2=[[UIButton alloc]initWithFrame:CGRectMake(j*60+10, i*70+50, 40, 40)];
                    [self.button setImage:[UIImage imageNamed:_hotArray[_countnum]] forState:UIControlStateNormal];
                    [self.button2 setTitle:_hotArray[_countnum] forState:UIControlStateNormal];
                    [self.button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                    [celltwo  addSubview:self.button2];
                    [celltwo addSubview:self.button];
                    _countnum++;
                }
            }
            return celltwo;
        }
        else
        {
            BrandCell*cell=[tableView dequeueReusableCellWithIdentifier:@"BrandCell"];
            cell.accessoryType=UITableViewCellStyleDefault;
            NSArray *arry=_titleArray[indexPath.section];
            //车系论坛推出的tableviewcell
            cell.textLabel.text=arry[indexPath.row];
            cell.imageView.image=[UIImage imageNamed:arry[indexPath.row]];
            return cell;
        }
    }
    else if (tableView.tag==3002)
    {
        SecondCell *cell=[tableView dequeueReusableCellWithIdentifier:@"SecondCell"];
        cell.accessoryType=UITableViewCellStyleValue1;
        cell.textLabel.text=_shaiArray[indexPath.row];
       
        return cell;
        
    }
    else if (tableView.tag==3003)
    {
        thirdCell *cell=[tableView dequeueReusableCellWithIdentifier:@"thirdCell"];
        
        
        
        
        
        return cell;
        
    
        
        
    }
    else if (tableView.tag==3004)
    {
        
        fourthCell *cell=[tableView dequeueReusableCellWithIdentifier:@"fourthCell"];
        
        cell.textLabel.text=_findArray[indexPath.row];
        return cell;
        
        
        
        
    }
    else if (tableView.tag==4001)
    {
    
        
        HotCell *cell=[tableView dequeueReusableCellWithIdentifier:@"HotCell"];
        
        NSArray *arry=_dataArray[indexPath.section];
        NSDictionary *dic=arry[0];
        NSArray *newarry=dic[@"levelArray"];
        HotModel *model=newarry[indexPath.row];
        [cell.imgView setImageWithURL:[NSURL URLWithString:model.img]];
        cell.titleLabel.text=model.seriesname;
        cell.priceLabel.text=model.price;
        cell.rowLabel.text=[NSString stringWithFormat:@"%d",(int)indexPath.row+1];
        if (indexPath.row>2) {
            cell.tagimgView.image=[UIImage imageNamed:@"icon_ranking_grey.png"];
        }else
        {
            cell.tagimgView.image=[UIImage imageNamed:@"icon_ranking_yellow.png"];
        }
        return cell;
        
        
    }
    else
    {
        static NSString *resusedID=@"resusedID";
        UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:resusedID];
        if (!cell) {
            cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:resusedID];
            
        }
        return cell;
        
    }
}



-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag==3001)
    {
        if (indexPath.section==0)
        {
            return 170;
        }
        else
        {
            return 50;
        }
    }
    else if (tableView.tag==3002)
    {
        
        return 40;
        
        
    }
    else if (tableView.tag==3003)
    {
        
        return 130;
        
        
    }
    else if(tableView.tag==3004)
    {
        
        return 40;
        
        
    }
    else if (tableView.tag==4001)
    {
        
        return 100;
        
    }
    else
    {
        return 50;
        
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    
    if (tableView.tag==3001) {
        return 0;
    }else if (tableView.tag==3002){
        return 50;
    }else if (tableView.tag==3003)
    {
        return 2;
        
        
    }
    else if(tableView.tag==3004)
    {
        
        return 3;
        
    }
    else if (tableView.tag==4001)
    {
        
        return 1;
        
    }
    else
    {
    return 30;
    }
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (tableView.tag==3001) {
        
    
    switch (section) {
        case 0:
            return @"热门品牌";
            break;
        case 1:
            return _searchArray[1];
            break;
        case 2:
            return _searchArray[2];
            break;
        case 3:
            return _searchArray[3];
            break;
        case 4:
            return _searchArray[4];
            break;
        case 5:
            return _searchArray[5];
            break;
        case 6:
            return _searchArray[6];
            break;
        case 7:
            return _searchArray[7];
            break;
        case 8:
            return _searchArray[8];
            break;
        case 9:
            return _searchArray[9];
            break;
        case 10:
            return _searchArray[10];
            
            break;
        case 11:
            return _searchArray[11];
            break;
        case 12:
            return _searchArray[12];
            break;
        case 13:
            return _searchArray[13];
            break;
        case 14:
            return _searchArray[14];
            break;
        case 15:
            return _searchArray[15];
            break;
        case 16:
            return _searchArray[16];
            break;
        case 17:
            return _searchArray[17];
            break;
        case 18:
            return _searchArray[18];
            break;
        case 19:
            return _searchArray[19];
            break;
        case 20:
            return _searchArray[20];
            break;
        case 21:
            return _searchArray[21];
            break;
        case 22:
            return _searchArray[22];
            break;
        case 23:
            return _searchArray[23];
            break;
        case 24:
            return _searchArray[24];
            break;
            
            
            
            
        default:
            break;
    }
    
    return nil;
    }
    else if (tableView.tag==3004)
    {
        
        return @"筛选条件";
    }
    else if (tableView.tag==4001)
    {
        
        NSArray *arry=_dataArray[section];
        NSDictionary *dic=arry[0];
        NSString *headtitle=dic[@"levelname"];
        
        return headtitle;
        
    }
    else
    {
        
        return nil;
    }
    
    
    
    
}


-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    if (tableView.tag==3001)
    {
    return _searchArray;
    }
    else
    {
        return nil;
        
    }
    
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
